import {
  defineConfig
} from 'vite'
import vue from '@vitejs/plugin-vue'
import {
  resolve
} from 'path'
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    // 设置路径别名
    alias: {
      '@': resolve(__dirname, './src'),
      '*': resolve('')
    },
  },
  server: {
    proxy: {
      '/user': {
        target: 'http://huaan_api.hfshuoxian.cn', //目标url
        changeOrigin: true, //支持跨域
        rewrite: (path) => path.replace(/^\/user/, ""),
        // rewrite: (path) => path.replace(/^\/token/, ""),
        //重写路径,替换/api
      },
      '/plant': {
        target: 'http://ceshifanyi.haiba.tech', //目标url
        changeOrigin: true, //支持跨域
        ws: true,
        secure: false,
        rewrite: (path) => path.replace(/^\/plant/, "")
        // pathR
      },
    },

  }
  // resolve: {
  //   alias: {
  //     "@": path.resolve(__dirname, src)
  //   }
  // }
})